<?php
namespace app\admin\controller;
use think\Controller;
class Base extends Controller
{
	public function initialize(){
		if(!session('username')){
            $this->redirect(url('login/login'));
        }
	}
	// 原图上传
    public function uploadtmd(){
        $photo='';
        $imgpath="../public/uploads/images/";
        $imgsubpath=date('Ymd',time())."/";
        if(!file_exists($imgpath)){
            mkdir($imgpath,0777);
        }
        if(!file_exists($imgpath.$imgsubpath)){
            mkdir($imgpath.$imgsubpath,0777);
        }
        chmod($imgpath.$imgsubpath,0777);
        if(isset($_FILES['file'])){
            move_uploaded_file($_FILES['file']['tmp_name'],$imgpath.$imgsubpath.$_FILES['file']['name']);
            $photo="/uploads/images/".$imgsubpath.$_FILES['file']['name'];
        }
        return json(['code' => 200, 'photo' =>$photo, 'msg' => '成功']);
    }
}